<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body onload="setTimeout(runTest, 1)">

<div id="console"></div>

<input id="emptyOnFirstVisit" />
<form action="../../resources/back.html" name=f>
    <input type="hidden" name="hidden" value="before" />
</form>

<script>
description("webkit.org/b/77391 - Hidden form elements do not save their state prior to form submission; crbug.com/651822 - Stop to save state for hidden type.");

window.jsTestIsAsync = true;

function runTest() {
    var state = document.getElementById("emptyOnFirstVisit");
    if (!state.value) {
        // First visit.
        if (window.testRunner)
            testRunner.waitUntilDone();
        state.value = "visited";

        document.f.hidden.value = "after";
        // Submit form in a timeout to make sure that we create a new back/forward list item.
        setTimeout(function() {document.f.submit();}, 0);
    } else {
        // Second visit.
        shouldBeEqualToString("document.f.hidden.value", "before");
        successfullyParsed = true;

        finishJSTest();
    }
}
</script>
</body>
